package com.lyb.spzx.manager.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lyb.spzx.manager.mapper.ProductSpecMapper;
import com.lyb.spzx.manager.service.ProductSpecService;
import com.lyb.spzx.model.entity.product.ProductSpec;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class ProductSpecServiceImpl implements ProductSpecService {

    @Autowired
    ProductSpecMapper productSpecMapper;
    @Override
    public PageInfo<ProductSpec> findById(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<ProductSpec> productSpecList = productSpecMapper.findById();
        return new PageInfo<>(productSpecList);
    }

    @Override
    public void svaeSpec(ProductSpec productSpec) {
        productSpecMapper.saveSpec(productSpec);
    }

    @Override
    public void updateSpec(ProductSpec productSpec) {
        productSpecMapper.updateSpec(productSpec);
    }

    @Override
    public void deleteSpec(Long id) {
        productSpecMapper.deleteSpec(id);
    }

    @Override
    public List<ProductSpec> findAllSpec() {
        List<ProductSpec> productSpecList = productSpecMapper.findAllSpec();
        return productSpecList;
    }
}
